package com.zlx.store.order.config;

import com.zlx.store.order.job.CleanExpireOrder;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CleanJobConfig {

    /**
     * 启动哪个人物
     *
     * @return
     */
    @Bean
    public JobDetail jobDetail() {
        return JobBuilder.newJob(CleanExpireOrder.class)
                .storeDurably(true)
                .build();
    }

    /**
     * 什么时间触发启动
     * 五年启动一次
     *
     * @return
     */
    @Bean
    public Trigger trigger() {
        return TriggerBuilder.newTrigger()
                .forJob(jobDetail())
                .withSchedule(CronScheduleBuilder.cronSchedule("0 31 11 6 8 ? 2028+5"))
                .build();
    }
}
